package com.sharer.last.enums;

import com.sharer.last.base.enums.SiteSettingTypeEnum;
import com.sharer.last.model.po.SiteSettingPO;
import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 站点标签枚举
 *
 * @ClassName SiteSettingTagEnum
 * @Author WangJin
 * @Date 2023/06/28/10:55
 * @Description
 * @Version 1.0
 */
@Getter
public enum SiteSettingTagEnum {
    /**
     * 博客名称
     */
    BLOG_NAME(1, 1, "blogName", "博客名称", "Your Name's Blog"),
    /**
     * 网页标题后缀
     */
    WEB_TITLE_SUFFIX(1, 2, "webTitleSuffix", "网页标题后缀", "- Your Name's Blog"),
    /**
     * 页脚图片标题
     */
    FOOTER_IMG_TITLE(1, 3, "footerImgTitle", "页脚图片标题", "手机看本站"),
    /**
     * 页脚图片路径
     */
    FOOTER_IMG_URL(1, 4, "footerImgUrl", "页脚图片路径", ""),
    /**
     * Copyright
     */
    COPYRIGHT(1, 5, "copyright", "Copyright", "{\"title\":\"Copyright © 2019 - 2022\",\"siteName\":\"Your Name'S BLOG\"}"),
    /**
     * ICP备案号
     */
    BEI_AN(1, 6, "beian", "ICP备案号", ""),
    /**
     * 赞赏码
     */
    REWARD(1, 7, "reward", "赞赏码", "赞赏码图片url"),
    /**
     * 博主评论标识
     */
    COMMENT_ADMIN_FLAG(1, 8, "commentAdminFlag", "博主评论标识", "咕咕"),
    /**
     * 播放器平台
     */
    PLAY_LIST_SERVER(1, 8, "playlistServer", "播放器平台", "netease"),
    /**
     * 播放器歌单
     */
    PLAY_LIST_ID(1, 10, "playlistId", "播放器歌单", "3071528549"),
    /**
     * 头像
     */
    AVATAR(2, 11, "avatar", "头像", "头像url"),
    /**
     * 昵称
     */
    NAME(2, 12, "name", "昵称", "昵称"),
    /**
     * 滚动个签
     */
    ROLL_TEXT(2, 13, "rollText", "滚动个签", "\"云鹤当归天，天不迎我妙木仙；\",\"游龙当归海，海不迎我自来也。\""),
    /**
     * GitHub
     */
    GITHUB(2, 14, "github", "GitHub", "url"),
    /**
     * Telegram
     */
    TELEGRAM(2, 15, "telegram", "Telegram", "url"),
    /**
     * QQ
     */
    QQ(2, 16, "qq", "QQ", "http://sighttp.qq.com/authd?IDKEY="),
    /**
     * 哔哩哔哩
     */
    BILIBILI(2, 17, "bilibili", "哔哩哔哩", "https://space.bilibili.com/"),
    /**
     * 网易云音乐
     */
    NETEASE(2, 18, "netease", "网易云音乐", "https://music.163.com/#/user/home?id="),
    /**
     * 邮箱
     */
    EMAIL(2, 19, "email", "邮箱", ""),
    /**
     * 友链页面信息
     */
    FRIEND_CONTENT(3, 20, "friendContent", "友链页面信息", ""),
    /**
     * 友链页面评论开关
     */
    FRIEND_COMMENT_ENABLED(3, 21, "friendCommentEnabled", "友链页面评论开关", "1"),
    /**
     * 徽标
     */
    BADGE(4, 22, "badge", "徽标", "{\"color\":\"\",\"subject\":\"\",\"title\":\"\",\"url\":\"\",\"value\":\"\"}"),
    /**
     * 自定义
     */
    FAVORITE(5, 23, "favorite", "自定义", "{\"title\":\"\",\"content\":\"\"}"),
    ;

    private static final Map<String, List<SiteSettingPO>> STATUS_MAP = new HashMap<>();

    static {
        for (SiteSettingTagEnum aEnum : SiteSettingTagEnum.values()) {
            Integer             settingType = aEnum.getSiteSettingType();
            SiteSettingTypeEnum typeEnum    = SiteSettingTypeEnum.getTypeEnum(settingType);
            if (typeEnum != null) {
                String              keyName        = typeEnum.getNameEn();
                List<SiteSettingPO> siteSettingPOS = STATUS_MAP.get(keyName);
                if (siteSettingPOS == null) {
                    siteSettingPOS = new ArrayList<>();
                }
                SiteSettingPO siteSettingPO = SiteSettingPO.builder()
                        .siteSettingType(aEnum.getSiteSettingType())
                        .tagType(aEnum.getTagType())
                        .nameEn(aEnum.getNameEn())
                        .nameZh(aEnum.getNameZh())
                        .value(aEnum.getValue())
                        .build();
                siteSettingPOS.add(siteSettingPO);
                STATUS_MAP.put(keyName, siteSettingPOS);
            }
        }
    }

    private Integer siteSettingType;

    private Integer tagType;

    private String nameEn;

    private String nameZh;

    private String value;

    SiteSettingTagEnum(Integer siteSettingType, Integer tagType, String nameEn, String nameZh, String value) {
        this.siteSettingType = siteSettingType;
        this.tagType = tagType;
        this.nameEn = nameEn;
        this.nameZh = nameZh;
        this.value = value;
    }

    public static Map<String, List<SiteSettingPO>> getMap() {
        return STATUS_MAP;
    }
}
